package com.bls.executor.node.sentence.simpleStmt;


import com.bls.exception.MyException;
import com.bls.executor.parser.V3Parser;
import com.bls.executor.word.noun.Band;
import com.bls.executor.word.noun.Tool;
import com.bls.executor.word.noun.Unit;
import com.bls.executor.word.noun.User;

import java.util.HashMap;
import java.util.Map;

public class RunToolStmt extends IntenseStmt {
    //A在B帮区执行C工具D部件，参数为XX
    private User user;
    private Band band;
    private Tool tool;
    private Unit unit;
    private HashMap<String,Object> param;

    public RunToolStmt() {
    }

    public RunToolStmt(V3Parser.RunToolStmtContext ctx, Map<String, Object> scriptEnvironment) throws MyException {
        band = new Band(ctx.place().Identifier().getText(), scriptEnvironment);
        user = new User(ctx.Identifier().get(0).getText(), scriptEnvironment);
        tool = new Tool(ctx.Identifier().get(1).getText(), scriptEnvironment, band.getBandId());
        unit = new Unit(ctx.Identifier().get(2).getText(), scriptEnvironment);
        String result = ctx.Identifier().get(3).getText();
        System.out.println("返回结果为：" + result);
    }

    @Override
    public boolean run(String url) {
        // 工具调用的url
        System.out.println("调用工具："+tool.text);
        return true;
    }
}
